home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / hurd / fd-write.c < prev    next >
C/C++ Source or Header  |  1994-05-11  |  2KB  |  72 lines

  1. /* Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #include <errno.h>
  20. #include <unistd.h>
  21. #include <hurd.h>
  22. #include <hurd/fd.h>
  23.  
  24. error_t
  25. _hurd_fd_write (struct hurd_fd *fd, const void *buf, size_t *nbytes)
  26. {
  27.   error_t err;
  28.   mach_msg_type_number_t wrote;
  29.   int noctty;
  30.  
  31. #ifdef notyet
  32.   struct _hurd_sigstate *ss = _hurd_self_sigstate ();
  33.  
  34.   /* Don't use the ctty io port if we are orphaned, or are blocking or
  35.      ignoring SIGTTOU.  */
  36.   noctty = (_hurd_orphaned ||
  37.         __sigismember (SIGTTOU, &ss->blocked) ||
  38.         ss->actions[SIGTTOU].sa_handler == SIG_IGN);
  39.   __mutex_unlock (&ss->lock);
  40. #else
  41.   noctty = 1;
  42. #endif
  43.   
  44.   err = HURD_FD_PORT_USE
  45.     (fd,
  46.      ({
  47.      call:
  48.        err = __io_write (noctty ? port : ctty, buf, *nbytes, -1, &wrote);
  49.        if (!noctty && ctty != MACH_PORT_NULL && err == EBACKGROUND)
  50.      {
  51. #if 1
  52.        abort ();
  53. #else
  54.        int restart;
  55.        __mutex_lock (&ss->lock);
  56.        restart = ss->actions[SIGTTOU].sa_flags & SA_RESTART;
  57.        _hurd_raise_signal (ss, SIGTTOU, 0); /* Unlocks SS->lock.  */
  58.        if (restart)
  59.          goto call;
  60.        else
  61.          err = EINTR;    /* XXX Is this right? */
  62. #endif
  63.      }
  64.        err;
  65.      }));
  66.  
  67.   if (! err)
  68.     *nbytes = wrote;
  69.  
  70.   return err;
  71. }
  72.